<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jQuery/js/jquery-1.12.4.min.js"></script>
    <script>
        $(function(){
            var $div1 = $('div');
            var $p1=$div1.has('p').css({background:'black'});
            $div1.eq(1).css({background:'blue'});
        })
    </script>
</head>
<body>
    <div>
        <p>haha</p>
    </div>
    <div>
        <input type="button" value="点我">
    </div>
</body>
</html>